﻿#include "deviceframework.h"
#include "newcomdevicedialog.h"
#include "newnetdevicedialog.h"
#include "newddsdevicedialog.h"
#include "newsimdevicedialog.h"
#include "qsoftcore.h"
#include "qprojectcore.h"
#include "public/userevent.h"
#include <QMenu>
#include <QAction>
#include <QIcon>
#include <QKeySequence>
#include <QContextMenuEvent>
#include <QFile>

/**
 * 整个操作过程如下：
 * 1、在DevRunner::Load方法中加载项目工程信息
 * 2、加载工程信息，并获取设备信息及设备协议，如Sim设备,RandomGen为生成协议
 * 3、加载插件
 * 4、绑定device与port
 * 5、依据变量表，创建RtTag，并加入到设备Tag清单
 * 6、启动Port线程，定时向device获取数据
 * 7、在ReadTags中，获取所有Tag数据
 * 8、在ReadTag中，藜取单个Tag数据
 * @brief DeviceFramework::DeviceFramework
 * @param parent
 */

DeviceFramework::DeviceFramework(QWidget *parent) : QWidget(parent)
{
    setAttribute(Qt::WA_DeleteOnClose);

    m_pListViewCommDevObj = new ListViewEx(this);
    m_pListViewCommDevObj->setViewMode(QListView::IconMode);
    m_pListViewCommDevObj->setViewportMargin(0, 0, 0, 0);
    m_pListViewCommDevObj->setIconSize(QSize(32, 32));
    m_pListViewCommDevObj->setGridSize(QSize(120, 120));
    m_pListViewCommDevObj->setWordWrap(true);
    m_pListViewCommDevObj->setSpacing(20);
    m_pListViewCommDevObj->setResizeMode(QListView::Adjust);
    m_pListViewCommDevObj->setMovement(QListView::Static);
    connect(m_pListViewCommDevObj, &QAbstractItemView::doubleClicked, this,
            &DeviceFramework::onSlotListViewProjectDoubleClicked);

    QVBoxLayout *pVLayoutObj = new QVBoxLayout(this);
    pVLayoutObj->setSpacing(0);
    pVLayoutObj->setContentsMargins(0, 0, 0, 0);
    pVLayoutObj->addWidget(m_pListViewCommDevObj);
    this->setLayout(pVLayoutObj);

    m_pCommDevModelObj = new QStandardItemModel();
    m_pListViewCommDevObj->setModel(m_pCommDevModelObj);

    setContextMenuPolicy(Qt::DefaultContextMenu);
}

DeviceFramework::~DeviceFramework()
{
    if(m_pCommDevModelObj != NULL) {
        delete m_pCommDevModelObj;
        m_pCommDevModelObj = NULL;
    }
    if(m_pListViewCommDevObj != NULL) {
        delete m_pListViewCommDevObj;
        m_pListViewCommDevObj = NULL;
    }
}


void DeviceFramework::listViewUISetting()
{
    m_pListViewCommDevObj->setViewMode(QListView::IconMode);
    m_pListViewCommDevObj->setViewportMargin(0, 0, 0, 0);
    m_pListViewCommDevObj->setIconSize(QSize(32, 32));
    m_pListViewCommDevObj->setGridSize(QSize(120, 120));
    m_pListViewCommDevObj->setWordWrap(true);
    m_pListViewCommDevObj->setSpacing(20);
    m_pListViewCommDevObj->setResizeMode(QListView::Adjust);
    m_pListViewCommDevObj->setMovement(QListView::Static);
}

void DeviceFramework::listViewUpdate()
{
    qDebug() << "DeviceFramework::listViewUpdate" << m_szItemName ;
    if(m_szItemName == QString("DeviceFramework").toUpper()) { // 通讯设备
        listViewDeviceFrameworkUpdate();
    } else if(m_szItemName == QString("ComDevice").toUpper()) { // 串口设备
        listViewCOMDeviceUpdate();
    } else if(m_szItemName == QString("NetDevice").toUpper()) { // 网络设备
        listViewNetDeviceUpdate();
    } else if(m_szItemName == QString("DdsDevice").toUpper()) { // 消息设备
        listViewDdsDeviceUpdate();
    } else if(m_szItemName == QString("SimDevice").toUpper()) { // 模拟设备
        listViewSimDeviceUpdate();
    }
}

/**
 * @brief DeviceFramework::listViewDeviceFrameworkUpdate
 * @details 所有通讯设备列表视图
 */
void DeviceFramework::listViewDeviceFrameworkUpdate()
{
    qDebug() << "DeviceFramework::listViewDeviceFrameworkUpdate";
    m_pCommDevModelObj->clear();
    listViewUISetting();

    QStandardItem *pNewComDevice = new QStandardItem(QIcon(":/images/pj_com.png"), tr("新建串口设备"));
    pNewComDevice->setEditable(false);
    pNewComDevice->setData(QString("NewComDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewComDevice);

    QStandardItem *pNewNetDevice = new QStandardItem(QIcon(":/images/pj_net.png"), tr("新建网络设备"));
    pNewNetDevice->setEditable(false);
    pNewNetDevice->setData(QString("NewNetDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewNetDevice);
/*
    QStandardItem *pNewBusDevice = new QStandardItem(QIcon(":/images/pj_bus.png"), tr("新建总线设备"));
    pNewBusDevice->setEditable(false);
    pNewBusDevice->setData(QString("NewBusDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewBusDevice);

    QStandardItem *pNewOPCDevice = new QStandardItem(QIcon(":/images/pj_opc.png"), tr("新建OPC设备"));
    pNewOPCDevice->setEditable(false);
    pNewOPCDevice->setData(QString("NewOPCDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewOPCDevice);
*/
    QStandardItem *pNewDdsDevice = new QStandardItem(QIcon(":/images/pj_opc.png"), tr("新建DDS设备"));
    pNewDdsDevice->setEditable(false);
    pNewDdsDevice->setData(QString("NewDdsDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewDdsDevice);
    QStandardItem *pNewSimDevice = new QStandardItem(QIcon(":/images/pj_opc.png"), tr("新建模拟设备"));
    pNewSimDevice->setEditable(false);
    pNewSimDevice->setData(QString("NewSimDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewSimDevice);


    ////////////////////////////////////////////////////////////////////////////

    DeviceInfo &deviceInfo = QSoftCore::getCore()->getProjectCore()->m_deviceInfo;
    for(int i = 0; i < deviceInfo.m_listDeviceInfoObject.count(); i++) {
        DeviceInfoObject *pObj = deviceInfo.m_listDeviceInfoObject.at(i);
        if(pObj->m_deviceType == "COM") {
            QStandardItem *pNewComDevice = new QStandardItem(QIcon(":/images/pj_com.png"), pObj->m_name);
            pNewComDevice->setEditable(false);
            pNewComDevice->setData(pObj->m_name, Qt::UserRole + 1);
            m_pCommDevModelObj->appendRow(pNewComDevice);
        } else if(pObj->m_deviceType == "NET") {
            QStandardItem *pNewNetDevice = new QStandardItem(QIcon(":/images/pj_net.png"), pObj->m_name);
            pNewNetDevice->setEditable(false);
            pNewNetDevice->setData(pObj->m_name, Qt::UserRole + 1);
            m_pCommDevModelObj->appendRow(pNewNetDevice);
        } else if(pObj->m_deviceType == "DDS") {
            QStandardItem *pNewDdsDevice = new QStandardItem(QIcon(":/images/pj_net.png"), pObj->m_name);
            pNewDdsDevice->setEditable(false);
            pNewDdsDevice->setData(pObj->m_name, Qt::UserRole + 1);
            m_pCommDevModelObj->appendRow(pNewDdsDevice);
        } else if(pObj->m_deviceType == "SIM") {
            QStandardItem *pNewSimDevice = new QStandardItem(QIcon(":/images/pj_net.png"), pObj->m_name);
            pNewSimDevice->setEditable(false);
            pNewSimDevice->setData(pObj->m_name, Qt::UserRole + 1);
            m_pCommDevModelObj->appendRow(pNewSimDevice);
        }
    }
}

/**
 * @brief DeviceFramework::listViewCOMDeviceUpdate
 * @details 串口通讯设备列表视图
 */
void DeviceFramework::listViewCOMDeviceUpdate()
{
    m_pCommDevModelObj->clear();
    listViewUISetting();

    QStandardItem *pNewComDevice = new QStandardItem(QIcon(":/images/pj_com.png"), tr("新建串口设备"));
    pNewComDevice->setEditable(false);
    pNewComDevice->setData(QString("NewComDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewComDevice);

    DeviceInfo &deviceInfo = QSoftCore::getCore()->getProjectCore()->m_deviceInfo;
    for(int i = 0; i < deviceInfo.m_listDeviceInfoObject.count(); i++) {
        DeviceInfoObject *pObj = deviceInfo.m_listDeviceInfoObject.at(i);
        if(pObj->m_deviceType == "COM") {
            QStandardItem *pComDevice = new QStandardItem(QIcon(":/images/pj_com.png"), pObj->m_name);
            pComDevice->setEditable(false);
            pComDevice->setData(pObj->m_name, Qt::UserRole + 1);
            m_pCommDevModelObj->appendRow(pComDevice);
        }
    }
}

/**
 * @brief DeviceFramework::listViewNetDeviceUpdate
 * @details 网络通讯设备列表视图
 */
void DeviceFramework::listViewNetDeviceUpdate()
{
    m_pCommDevModelObj->clear();
    listViewUISetting();

    QStandardItem *pNewNetDevice = new QStandardItem(QIcon(":/images/pj_net.png"), tr("新建网络设备"));
    pNewNetDevice->setEditable(false);
    pNewNetDevice->setData(QString("NewNetDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewNetDevice);

    DeviceInfo &deviceInfo = QSoftCore::getCore()->getProjectCore()->m_deviceInfo;
    for(int i = 0; i < deviceInfo.m_listDeviceInfoObject.count(); i++) {
        DeviceInfoObject *pObj = deviceInfo.m_listDeviceInfoObject.at(i);
        if(pObj->m_deviceType == "NET") {
            QStandardItem *pNetDevice = new QStandardItem(QIcon(":/images/pj_net.png"), pObj->m_name);
            pNetDevice->setEditable(false);
            pNetDevice->setData(pObj->m_name, Qt::UserRole + 1);
            m_pCommDevModelObj->appendRow(pNetDevice);
        }
    }
}



/**
 * @brief DeviceFramework::listViewNetDeviceUpdate
 * @details 网络通讯设备列表视图
 */
void DeviceFramework::listViewDdsDeviceUpdate()
{
    m_pCommDevModelObj->clear();
    listViewUISetting();

    QStandardItem *pNewDdsDevice = new QStandardItem(QIcon(":/images/pj_net.png"), tr("新建数据订阅设备"));
    pNewDdsDevice->setEditable(false);
    pNewDdsDevice->setData(QString("NewDdsDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewDdsDevice);

    DeviceInfo &deviceInfo = QSoftCore::getCore()->getProjectCore()->m_deviceInfo;
    for(int i = 0; i < deviceInfo.m_listDeviceInfoObject.count(); i++) {
        DeviceInfoObject *pObj = deviceInfo.m_listDeviceInfoObject.at(i);
        if(pObj->m_deviceType == "DDS") {
            QStandardItem *pDdsDevice = new QStandardItem(QIcon(":/images/pj_net.png"), pObj->m_name);
            pDdsDevice->setEditable(false);
            pDdsDevice->setData(pObj->m_name, Qt::UserRole + 1);
            m_pCommDevModelObj->appendRow(pDdsDevice);
        }
    }
}



/**
 * @brief DeviceFramework::listViewNetDeviceUpdate
 * @details 网络通讯设备列表视图
 */
void DeviceFramework::listViewSimDeviceUpdate()
{
    m_pCommDevModelObj->clear();
    listViewUISetting();

    QStandardItem *pNewSimDevice = new QStandardItem(QIcon(":/images/pj_net.png"), tr("新建数据仿真设备"));
    pNewSimDevice->setEditable(false);
    pNewSimDevice->setData(QString("NewSimDevice").toUpper(), Qt::UserRole + 1);
    m_pCommDevModelObj->appendRow(pNewSimDevice);

    DeviceInfo &deviceInfo = QSoftCore::getCore()->getProjectCore()->m_deviceInfo;
    for(int i = 0; i < deviceInfo.m_listDeviceInfoObject.count(); i++) {
        DeviceInfoObject *pObj = deviceInfo.m_listDeviceInfoObject.at(i);
        if(pObj->m_deviceType == "SIM") {
            QStandardItem *pSimDevice = new QStandardItem(QIcon(":/images/pj_net.png"), pObj->m_name);
            pSimDevice->setEditable(false);
            pSimDevice->setData(pObj->m_name, Qt::UserRole + 1);
            m_pCommDevModelObj->appendRow(pSimDevice);
        }
    }
}

/*
* 右键菜单
*/
void DeviceFramework::contextMenuEvent(QContextMenuEvent * event)
{
    QModelIndex index = m_pListViewCommDevObj->indexAt(event->pos());
    if(!index.isValid()) { // 单击空白部分
        return;
    }

    QMenu *pMenu = new QMenu(this);

    QAction *pModifyAct = new QAction(QIcon(":/images/icon_modify.png"), tr("修改"), this);
    //pModifyAct->setShortcut(QKeySequence(Qt::ALT + Qt::Key_M));
    pModifyAct->setStatusTip(tr("修改设备参数"));
    connect(pModifyAct, SIGNAL(triggered()), this, SLOT(onSlotModifyDevice()));
    pMenu->addAction(pModifyAct);

    QAction *pDeleteAct = new QAction(QIcon(":/images/icon_delete.png"), tr("删除"), this);
    //pDeleteAct->setShortcut(QKeySequence(Qt::ALT + Qt::Key_D));
    pDeleteAct->setStatusTip(tr("删除通讯设备"));
    connect(pDeleteAct, SIGNAL(triggered()), this, SLOT(onSlotDeleteDevice()));
    pMenu->addAction(pDeleteAct);

    if(!pMenu->isEmpty()) {
        pMenu->move(cursor().pos());
        pMenu->exec();
        pMenu->clear();
    }
    delete pMenu;
}

/*
* 插槽：新建设备,存入项目xml文件中
*/
void DeviceFramework::onSlotNewDevice()
{
    if(QSoftCore::getCore()->getProjectCore()->m_szProjName == "") {
        return;
    }

    QList<QStandardItem *> itemList;

    if(m_szItemName == QString("NewComDevice").toUpper()) { // 串口设备
        itemList = m_pCommDevModelObj->findItems(tr("新建串口设备"));
        if(itemList.size() == 0) {
            return;
        }
        NewComDeviceDialog *pNewComDeviceDlg = new NewComDeviceDialog(this);
        pNewComDeviceDlg->load("");
        if(pNewComDeviceDlg->exec() == QDialog::Accepted) {
            pNewComDeviceDlg->save("");
        }
    } else if(m_szItemName == QString("NewNetDevice").toUpper()) { // 网络设备
        itemList = m_pCommDevModelObj->findItems(tr("新建网络设备"));
        if(itemList.size() == 0) {
            return;
        }
        NewNetDeviceDialog *pNewNetDeviceDlg = new NewNetDeviceDialog(this);
        pNewNetDeviceDlg->load("");
        if(pNewNetDeviceDlg->exec() == QDialog::Accepted) {
            pNewNetDeviceDlg->save("");
        }
    } else if(m_szItemName == QString("NewDdsDevice").toUpper()) { // DDS设备
        itemList = m_pCommDevModelObj->findItems(tr("新建DDS设备"));
        if(itemList.size() == 0) {
            return;
        }
        NewDdsDeviceDialog *pNewDdsDeviceDlg = new NewDdsDeviceDialog(this);
        pNewDdsDeviceDlg->load("");
        if(pNewDdsDeviceDlg->exec() == QDialog::Accepted) {
            pNewDdsDeviceDlg->save("");
        }
    } else if(m_szItemName == QString("NewSimDevice").toUpper()) { // 模拟设备
        itemList = m_pCommDevModelObj->findItems(tr("新建模拟设备"));
        if(itemList.size() == 0) {
            return;
        }
        NewSimDeviceDialog *pNewSimDeviceDlg = new NewSimDeviceDialog(this);
        pNewSimDeviceDlg->load("");
        if(pNewSimDeviceDlg->exec() == QDialog::Accepted) {
            qDebug() << "DeviceFramework::onSlotNewDevice：Save Sim Device!";
            pNewSimDeviceDlg->save("");
        }
    }
    listViewUpdate();
}


/*
* 插槽：修改通讯设备参数
*/
void DeviceFramework::onSlotModifyDevice()
{
    QModelIndex idx = m_pListViewCommDevObj->selectionModel()->currentIndex();
    QStandardItem *pItemObj = m_pCommDevModelObj->itemFromIndex(idx);
    if(QSoftCore::getCore()->getProjectCore()->m_szProjName == "") {
        return;
    }

    DeviceInfo &deviceInfo = QSoftCore::getCore()->getProjectCore()->m_deviceInfo;
    DeviceInfoObject *pObj = deviceInfo.getObjectByName(pItemObj->text());
    if(pObj != NULL) {
        if(pObj->m_deviceType == "COM") {
            NewComDeviceDialog *pNewComDeviceDlg = new NewComDeviceDialog(this);
            pNewComDeviceDlg->load(pObj->m_name);
            pNewComDeviceDlg->exec();
            pObj->m_name = pNewComDeviceDlg->GetDeviceName();
            pObj->m_deviceName = pNewComDeviceDlg->pluginName();
            pNewComDeviceDlg->save(pObj->m_name);
        } else if(pObj->m_deviceType == "NET") {
            NewNetDeviceDialog *pNewNetDeviceDlg = new NewNetDeviceDialog(this);
            pNewNetDeviceDlg->load(pObj->m_name);
            pNewNetDeviceDlg->exec();
            pObj->m_name = pNewNetDeviceDlg->GetDeviceName();
            pObj->m_deviceName = pNewNetDeviceDlg->pluginName();
            pNewNetDeviceDlg->save(pObj->m_name);
        } else if(pObj->m_deviceType == "DDS") {
            NewDdsDeviceDialog *pNewDdsDeviceDlg = new NewDdsDeviceDialog(this);
            pNewDdsDeviceDlg->load(pObj->m_name);
            pNewDdsDeviceDlg->exec();
            pObj->m_name = pNewDdsDeviceDlg->GetDeviceName();
            pObj->m_deviceName = pNewDdsDeviceDlg->pluginName();
            pNewDdsDeviceDlg->save(pObj->m_name);
        } else if(pObj->m_deviceType == "SIM") {
            NewSimDeviceDialog *pNewSimDeviceDlg = new NewSimDeviceDialog(this);
            pNewSimDeviceDlg->load(pObj->m_name);
            pNewSimDeviceDlg->exec();
            pObj->m_name = pNewSimDeviceDlg->GetDeviceName();
            pObj->m_deviceName = pNewSimDeviceDlg->pluginName();
            pNewSimDeviceDlg->save(pObj->m_name);
        }
    }

    listViewUpdate();
}

/*
* 插槽：删除通讯设备
*/
void DeviceFramework::onSlotDeleteDevice()
{
    QModelIndex idx = m_pListViewCommDevObj->selectionModel()->currentIndex();
    QStandardItem *pItemObj = m_pCommDevModelObj->itemFromIndex(idx);

    DeviceInfo &deviceInfo = QSoftCore::getCore()->getProjectCore()->m_deviceInfo;
    for(int i = 0; i < deviceInfo.m_listDeviceInfoObject.count(); i++) {
        DeviceInfoObject *pObj = deviceInfo.m_listDeviceInfoObject.at(i);
        if(pItemObj->text() == pObj->m_name) {
            deviceInfo.m_listDeviceInfoObject.removeOne(pObj);
            break;
        }
    }

    listViewUpdate();
}


void DeviceFramework::onSlotListViewProjectDoubleClicked(const QModelIndex &index)
{

    qDebug() << "DeviceFramework::onSlotListViewProjectDoubleClicked";
    QStandardItem *pItemObj = m_pCommDevModelObj->itemFromIndex(index);
    if(QSoftCore::getCore()->getProjectCore()->m_szProjName == "") {
        return;
    }
    QString szItemText = pItemObj->data(Qt::UserRole + 1).toString();

    if(szItemText == QString("NewComDevice").toUpper()) { // 串口设备
        NewComDeviceDialog *pNewComDeviceDlg = new NewComDeviceDialog(this);
        pNewComDeviceDlg->load("");
        if(pNewComDeviceDlg->exec() == QDialog::Accepted) {
            pNewComDeviceDlg->save("");
        }
    } else if(szItemText == QString("NewNetDevice").toUpper()) { // 网络设备
        NewNetDeviceDialog *pNewNetDeviceDlg = new NewNetDeviceDialog(this);
        pNewNetDeviceDlg->load("");
        if(pNewNetDeviceDlg->exec() == QDialog::Accepted) {
            pNewNetDeviceDlg->save("");
        }
    } else if(szItemText == QString("NewDdsDevice").toUpper()) { // 数据订阅设备
        NewDdsDeviceDialog *pNewDdsDeviceDlg = new NewDdsDeviceDialog(this);
        pNewDdsDeviceDlg->load("");
        if(pNewDdsDeviceDlg->exec() == QDialog::Accepted) {
            pNewDdsDeviceDlg->save("");
        }
    } else if(szItemText == QString("NewSimDevice").toUpper()) { // 模拟设备
        NewSimDeviceDialog *pNewSimDeviceDlg = new NewSimDeviceDialog(this);
        pNewSimDeviceDlg->load("");
        if(pNewSimDeviceDlg->exec() == QDialog::Accepted) {
            pNewSimDeviceDlg->save("");
        }
    } else {
        DeviceInfo &deviceInfo = QSoftCore::getCore()->getProjectCore()->m_deviceInfo;
        DeviceInfoObject *pObj = deviceInfo.getObjectByName(pItemObj->text());
        if(pObj != NULL) {
            if(pObj->m_deviceType == "COM") {
                NewComDeviceDialog *pNewComDeviceDlg = new NewComDeviceDialog(this);
                pNewComDeviceDlg->load(pObj->m_name);
                pNewComDeviceDlg->exec();
                pObj->m_name = pNewComDeviceDlg->GetDeviceName();
                pObj->m_deviceName = pNewComDeviceDlg->pluginName();
                pNewComDeviceDlg->save(pObj->m_name);
            } else if(pObj->m_deviceType == "NET") {
                NewNetDeviceDialog *pNewDeviceDlg = new NewNetDeviceDialog(this);
                pNewDeviceDlg->load(pObj->m_name);
                pNewDeviceDlg->exec();
                pObj->m_name = pNewDeviceDlg->GetDeviceName();
                pObj->m_deviceName = pNewDeviceDlg->pluginName();
                pNewDeviceDlg->save(pObj->m_name);
            } else if(pObj->m_deviceType == "DDS") {
                NewDdsDeviceDialog *pNewDeviceDlg = new NewDdsDeviceDialog(this);
                pNewDeviceDlg->load(pObj->m_name);
                pNewDeviceDlg->exec();
                pObj->m_name = pNewDeviceDlg->GetDeviceName();
                pObj->m_deviceName = pNewDeviceDlg->pluginName();
                pNewDeviceDlg->save(pObj->m_name);
            } else if(pObj->m_deviceType == "SIM") {
                NewSimDeviceDialog *pNewDeviceDlg = new NewSimDeviceDialog(this);
                pNewDeviceDlg->load(pObj->m_name);
                pNewDeviceDlg->exec();
                pObj->m_name = pNewDeviceDlg->GetDeviceName();
                pObj->m_deviceName = pNewDeviceDlg->pluginName();
                pNewDeviceDlg->save(pObj->m_name);
            }
        }
    }
    listViewUpdate();
}


bool DeviceFramework::event(QEvent *ev)
{
    if(ev->type() == UserEvent::EVT_USER_SHOW_UPDATE) {
        UserEvent *pEvObj = dynamic_cast<UserEvent *>(ev);
        if(pEvObj) {
            m_szItemName = pEvObj->data().toString();
        }
        listViewUpdate();
        return true;
    } else if(ev->type() == UserEvent::EVT_USER_HIDE_UPDATE) {
        return true;
    }
    return QWidget::event(ev);
}


